﻿using Microsoft.AspNetCore.Http;
using OcelotWebapiService.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace OcelotWebapiService.Middlewares
{
    public class RequestMiddleware
    {
        private readonly RequestDelegate _next;
        public RequestMiddleware(RequestDelegate next)
        {
            _next = next;
        }
        public async Task Invoke(HttpContext httpContext)
        {
            var getFlag = ConfigHelper.GetValue("IfGetHead");
            var testString = ConfigHelper.GetValue("GlobalConfiguration:BaseUrl");
            if (getFlag.ToLower().Equals("true"))
            {
                var option = httpContext.Request.Query["option"];
                httpContext.Request.Headers["MyHead"] = "MyHEAD6666666";
            }
            await _next(httpContext);
        }
    }
}
